import request from '@/utils/request'

// 获取登录数据
export function login(data) {
  return request({
    method: 'POST',
    url: '/api/user-service/user/login',
    data
  })
}

export const add = (data) => {
  return request({
    method: 'post',
    url: '/api/vm-service/skuClass',
    data
  })
}

export const random = (params) => {
  return request({
    url: '/api/vm-service/skuClass/search',
    params: params
  })
}

export const edit = (classId, className) => {
  return request({
    url: `/api/vm-service/skuClass/${classId}`,
    method: 'put',
    data: { className }
  })
}
export const remove = (classId) => {
  return request({
    url: `/api/vm-service/skuClass/${classId}`,
    method: 'delete'
  })
}
export const search = (params) => {
  return request({
    url: '/api/vm-service/skuClass/search',
    method: 'get',
    params
  })
}

export const searchgoods = (params) => {
  return request({
    url: '/api/vm-service/sku/search',
    params
  })
}
export const addgoods = (data) => {
  return request({
    url: '/api/vm-service/sku',
    method: 'post',
    data
  })
}
export const editgoods = (id, data) => {
  return request({
    url: `/api/vm-service/sku/${id}`,
    method: 'put',
    data
  })
}
export function partnersRegion(params) {
  return request({
    url: '/api/user-service/partner/search',
    method: 'get',
    params
  })
}

export function getInfo(token) {
  return request({
    url: '/vue-admin-template/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/vue-admin-template/user/logout',
    method: 'post'
  })
}

// 获取用户个人资料
// 空格转义之后就是%20
export function getUserInfo() {
  return request({
    method: 'post',
    url: '/sys/profile'
  })
}
// 一种思路每个api都写一个headers

// 获取用户详情信息
export function getDetailUserInfo(id) {
  return request({
    url: `/sys/user/${id}`
  })
}

export const newCooperation = (data) => {
  return request({
    method: 'POST',
    url: '/api/user-service/partner',
    data
  })
}
// 删除合作商
export const delCooperation = (id) => {
  return request({
    method: 'DELETE',
    url: '/api/user-service/partner/' + id
  })
}
// 修改合作商
export const modifyPointCooperation = (id, data) => {
  return request({
    method: 'PUT',
    url: '/api/user-service/partner/' + id,
    data
  })
}
// 重置合作商密码
export const resetPassword = (id) => {
  return request({
    method: 'PUT',
    url: '/api/user-service/partner/resetPwd/' + id
  })
}
